#include "sphere.h"


#ifndef SPHERE_C
#define SPHERE_C
double sph_intersectionTime(Sphere s1, Ray r1){
  Vector cp;
  double v, discriminant;
  cp = sub(s1.center, r1.point);
  v = dot(cp, r1.vector);
  discriminant = (s1.radius * s1.radius) - (dot(cp,cp)-v*v);
  if (discriminant < 0)
    return 0.0;
  else
    return v - sqrt(discriminant);
};

Vector sph_normalAt(Sphere s1, Vector p){
  return normalized(sub(p, s1.center));
};


#endif
